package priv.wjh.study.concurrent.use;

/**
 * //TODO
 *
 * @author wangjunhao
 **/
public class Utils {
    public static String printBinary(long num) {
        StringBuilder binaryStr = new StringBuilder();
        for (int i = 0; i < 64; num >>= 1) {
            i++;
            binaryStr.append(num & 1);
            if ((i % 4) == 0 && i != 64) {
                binaryStr.append(" ");
            }
        }
        return binaryStr.reverse().toString();
    }

    public static String printBinary(int num) {
        StringBuilder binaryStr = new StringBuilder();
        for (int i = 0; i < 32; num >>= 1) {
            i++;
            binaryStr.append(num & 1);
            if ((i % 4) == 0 && i != 32) {
                binaryStr.append(" ");
            }
        }
        return binaryStr.reverse().toString();
    }
}
